package com.probiz.estore.order.dao.impl;

import java.sql.SQLException;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.probiz.estore.Constants;
import com.probiz.estore.common.model.order.OrderDelivery;
import com.probiz.estore.core.dao.impl.HibernateGenericDaoImpl;
import com.probiz.estore.order.dao.OrderDeliveryDao;

/**
 * Dao implementation for OrderDelivery.
*/
public class OrderDeliveryDaoImpl extends HibernateGenericDaoImpl<OrderDelivery> implements OrderDeliveryDao {
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.order.dao.OrderDeliveryDao#updateAllToDefaultFalse()
	 * 使用直接update语句提高性能。
	 */
	public void updateAllToDefaultFalse(){
		getHibernateTemplate().execute(new HibernateCallback() {
			public Object doInHibernate(Session session) throws HibernateException, SQLException {
				StringBuffer sb = new StringBuffer();
				sb.append("update order_delivery set isDefault = ").append(Constants.FLAG_FALSE);
				int i=session.createSQLQuery(sb.toString()).executeUpdate();
				return i;
			}

		});
	}
}
